<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>统计考试科目的成绩</title>
		<script>
			<!-- 
			function score() {
				var sum = 0;
				var score = new Array();
				var reg = /^[0-9]+.?[0-9]*$/;
				var num = window.prompt("请输入考试科目的数量：");
				if (num <= 0 || !reg.test(num)) {
					window.alert("输入的不是数字！");
					window.close();
				} else {
					for (let i = 0; i < num; i++) {
						score[i] = window.prompt("第" + (i + 1) + "科的成绩是：");
						sum += parseInt(score[i]);
					}
				}
				window.alert(num + "门科目的总成绩是：" + sum);
			}
			-->
		</script>
	</head>
	<body>
		<input type="button" value="统计考试科目的成绩" onclick="score()" />
	</body>
</html>
